package nl.science.uva.pico.operator;

import nl.science.uva.pico.Stack;
import nl.science.uva.pico.operand.Operand;

/** 
 * Minus negates the value on top of the stack 
 * 
 * @author Ivo van Dongen, Karel Pieterson
 * @version 1.0
 */
public class Minus extends Operator {

	public Minus(Stack stack) {
		super(stack, null, null);
	}
    /** 
     * Minus: This operation negates the value at the top of the stack 
     * (when it is an integer constant) and replaces the top of the stack by this value. 
     * 
     */
	@Override
	public void perform() {
		Integer operand = getStack().pop().getIntegerValue();
		Integer result =  -1 * operand;
		getStack().push(new Operand(result));
	}

}
